package sg.edu.nus.iss.vmcs.customer;

import java.awt.Button;
import java.awt.event.*;

public class CoinInputListener implements ActionListener {

	private CoinReceiver coinReceiver;
	
	public CoinInputListener(CoinReceiver coinReceiver){
		this.coinReceiver=coinReceiver;
	}
	
	public void actionPerformed(ActionEvent e){
		Button btn;
		String cmd;
		int idx;

		btn = (Button) e.getSource();
		cmd = btn.getActionCommand();
		idx = Integer.parseInt(cmd);

		int weight=coinReceiver.getTransactionController().getCustomerPanel().getCoinInputBox().getCoinWeight(idx);
		
		coinReceiver.receiveCoin(weight);
	}
}
